/*
 *    Copyright (c) 2023 李伟国
 *    moyu is licensed under Mulan PSL v2.
 *    You can use this software according to the terms and conditions of the Mulan PSL v2.
 *    You may obtain a copy of Mulan PSL v2 at:
 *             http://license.coscl.org.cn/MulanPSL2
 *    THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *    See the Mulan PSL v2 for more details.
 */

package cn.moyu.controller;

import cn.moyu.entity.KettleTransInfo;
import cn.moyu.entity.dto.KettleTransDto;
import cn.moyu.response.ResponseData;
import cn.moyu.response.SuccessResponseData;
import cn.moyu.service.IKettleTransInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 转换
 */

@RestController
@RequestMapping("kettle/trans")
public class KettleTransController {
    @Resource
    private IKettleTransInfoService kettleTransInfoService;

    /**
     * 获得转换列表
     * @param transName 转换名称
     * @param isUsed 是否启用
     * @return 结果
     */
    @RequestMapping(value = "list", method = RequestMethod.GET)
    public ResponseData getListPage(@RequestParam(value = "transName", required = false) String transName,
                                    @RequestParam(value = "isUsed", required = false) Integer isUsed) {
        Page<KettleTransInfo> listPage = kettleTransInfoService.getListPage(transName, isUsed);
        return new SuccessResponseData(listPage);
    }

    @RequestMapping(value = "", method = RequestMethod.POST)
    public ResponseData updateOrSave(@RequestBody @Validated KettleTransDto kettleTransDto){
        // TODO 更新或保存
        System.out.println(kettleTransDto);
        return new SuccessResponseData();
    }
}
